package com.mall.canal.config;

import org.apache.shardingsphere.elasticjob.reg.base.CoordinatorRegistryCenter;
import org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperConfiguration;
import org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperRegistryCenter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Darren
 * @date 2022-10-08 15:49
 * Description：
 */
@Configuration
public class ElasticConfig {
    @Value("${elaticjob.zookeeper.server-lists}")
    private String serverLists;
    @Value("${elaticjob.zookeeper.namespace}")
    private String namespace;

    @Bean
    public CoordinatorRegistryCenter createRegistryCenter() {
        CoordinatorRegistryCenter regCenter = new ZookeeperRegistryCenter(
                new ZookeeperConfiguration(serverLists, namespace));
        regCenter.init();
        return regCenter;
    }
}
